const loadBtn = document.querySelector('#loadBtn')

loadBtn.addEventListener('click', addScript)

function addScript() {
    const script = document.createElement('script')
    script.src = 'foo.js'
    document.head.appendChild(script)
}
